package com.enzoism.springboot.dive.map;

import com.enzoism.springboot.dive.model.UsrModel;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class TestMap {
    public static void main(String[] args) {
        List<UsrModel> dataList = UsrModel.initList();

        // 默认使用HashMap
        Map<String, Long> hashMap = dataList.stream().collect(Collectors.toMap(UsrModel::getUsrId, UsrModel::getClkNum, (item1, item2) -> item1));
        // 指定LinkedHashMap
        Map<String, Long> sortedMap = dataList.stream().collect(Collectors.toMap(UsrModel::getUsrId, UsrModel::getClkNum, (item1, item2) -> item1, LinkedHashMap::new));


    }
}
